using System.Collections;
using System.Collections.Generic;
using Commons;
using Datas;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class Card : ComMonoBehaviour, IPointerClickHandler
{
    // Start is called before the first frame update
    public List<EventCard> Cards = new List<EventCard>();

    public Text carTitle;
    public Text carDescription;
    public Image carImg;
    public Image[] imglist;
    
    /**随机事件的id*/
    public int ThisId;

    void Start()
    {
        ThisId = Random.Range(0, EventCardDb.Instance.EventCards.Count);
        Cards.Add(EventCardDb.Instance.EventCards[ThisId]);
       // carDescription.text = Cards[0].carDescription;
        RandomDescription(carDescription,ThisId);
        RandomCarImg(ThisId);
        
        
        carTitle.text = Cards[0].carTitle;
     
    }

    protected override void OnBeforeDestroy()
    {
    }

    // Update is called once per frame
    void Update()
    {
    }


    /**卡片被点击*/
    public void OnPointerClick(PointerEventData eventData)
    {
        //Debug.Log(Cards[0].carTitle+"点击"); 

        //发送卡片类型id的消息
        SendMsg(MsgData.ClickEventCard, Cards[0].id);
    }


    void RandomDescription(Text text,int index)
    {
        string[] Description = new string[4];
        
        Description[0] = "前方有个路口";
        Description[1] = "有个草丛";
        Description[2] = "前方有个大房子";
        Description[3] = "有个人影在前面";
        // Description[4] = "前方有个路口";
        // Description[5] = "前方有个路口";
        

        switch (index)
        {
            case (int)DialogType.Herbal:
                text.text = Description[Random.Range(0, 1)];
                break;
            case (int)DialogType.PatientEvent:
                text.text = Description[Random.Range(2, Description.Length)];
                break;
            case (int)DialogType.NextEvent:
                text.text = Description[0];
                break;
            case (int)DialogType.Merchant:
                text.text = Description[Random.Range(2, Description.Length)];
                break;
        }
    }

    void RandomCarImg(int carid)
    {
        switch (carid)
        {
            case (int)DialogType.Herbal :
                
                break;
        } 
    }
}